package com.demo11;

/**
 * Created by Administrator on 2017/4/14.
 */
public class Text {
    public static void main(String[] args) {
        String str = "We are students";
        int size = str.lastIndexOf(" ");
        System.out.println("空字符在字符串str中的索引位置是: " + size);
        System.out.println("字符串str的长度是: " + str.length());
        String str2 = "hello world";
        char mychar = str2.charAt(6);
        System.out.println("字符串str中索引位置是6的字符为: " + mychar);
        String str3 = "hello world";
        String substr = str3.substring(0, 3);
        System.out.println(substr);
        String str4 = "  Java  class  ";
        System.out.println("字符串原来的长度: " + str4.length());
        System.out.println("去掉空格后的长度: " + str4.trim().length());
    }
}
